package com.qingcheng.service.impl;

import com.qingcheng.dao.AdminInfoMapper;
import com.qingcheng.pojo.system.AdminInfo;
import com.qingcheng.service.AdminInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AdminInfoServiceImpl implements AdminInfoService {

    @Autowired
    private AdminInfoMapper adminInfoMapper;


    public List<AdminInfo> findAll() {
        return adminInfoMapper.selectAll();
    }

    public AdminInfo findById(Integer id) {
        return adminInfoMapper.selectByPrimaryKey(id);
    }

    public List<AdminInfo> findByParentId(Integer parentId) {
        Example example = new Example(AdminInfo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("parentId",parentId);
        return adminInfoMapper.selectByExample(example);
    }

    public void add(AdminInfo adminInfo) {
        adminInfoMapper.insert(adminInfo);
    }

    public void update(AdminInfo adminInfo) {
        adminInfoMapper.updateByPrimaryKeySelective(adminInfo);
    }

    public void delete(Integer id) {
        adminInfoMapper.deleteByPrimaryKey(id);
    }
}
